﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using DatePickerTemp.Models;

namespace DatePickerTemp.Controllers
{
    [OutputCache(Location = OutputCacheLocation.None)]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        [HttpGet]
        public ActionResult Edit()
        {
            FooEditModel model = new FooEditModel
                                     {
                                         Foo = new Foo
                                                   {
                                                       Name = "Stuart",
                                                       Date1 = new DateTime(2010, 12, 16),
                                                       Date2 = new DateTime(2010, 12, 16),
                                                       Date3 = new DateTime(2010, 12, 16),
                                                       Date4 = new DateTime(2010, 12, 16),
                                                   }
                                     };
            return View(model);
        }
        [HttpPost]
        public ActionResult Edit(Foo foo)
        {
            string message = null;
            if (ModelState.IsValid)
            {
                // would do validation & save here...
                message = "Saved " + DateTime.Now;
            }
            FooEditModel model = new FooEditModel
            {
                Foo = foo,
                Message = message
            };
            return View(model);
        }
    }
}
